package org.niu.listnode;

public class DaoshuK {
    public ListNode getKthFromEnd(ListNode head, int k) {
        ListNode p1=head,p = head;
        while(k!=0){
            k--;
            p=p.next;
        }
        while(p!=null){
            p=p.next;
            p1=p1.next;
        }
        return p1;
    }
}
